package com.showde.shoppingmall.business;

import com.showde.shoppingmall.business.NetCallbackImplBase.Notify;
import com.showde.shoppingmall.netentity.AddressEntity;
import com.showde.shoppingmall.netentity.AddressEntity.OPERATION_TYPE;

public class AddressBusiness extends BusinessBase {

	private String recipientName; // 收件人姓名
	private String recipientAddress; // 收件人地址
	private String recipientMobile; // 收件人手机号
	private String recipientPostCode; // 收件人邮编

	private String recipientAddressId; // 收件人地址id

	private OPERATION_TYPE operation_type; // 操作类型

	public AddressBusiness(String recipientName, String recipientAddress,
			String recipientMobile, String recipientPostCode, Notify notify) {
		super(notify);
		this.recipientName = recipientName;
		this.recipientAddress = recipientAddress;
		this.recipientMobile = recipientMobile;
		this.recipientPostCode = recipientPostCode;
		this.operation_type = OPERATION_TYPE.add;
		prepare();
	}

	public AddressBusiness(Notify notify) {
		super(notify);
		this.operation_type = OPERATION_TYPE.get;
		prepare();
	}

	public AddressBusiness(String addressId, Notify notify) {
		super(notify);
		recipientAddressId = addressId;
		this.operation_type = OPERATION_TYPE.delete;
		prepare();
	}

	public AddressBusiness(String recipientName, String recipientAddress,
			String recipientMobile, String recipientPostCode,
			String recipientAddressId, Notify notify) {
		super(notify);
		this.recipientName = recipientName;
		this.recipientAddress = recipientAddress;
		this.recipientMobile = recipientMobile;
		this.recipientPostCode = recipientPostCode;
		this.recipientAddressId = recipientAddressId;
		this.operation_type = OPERATION_TYPE.update;
		prepare();
	}

	@Override
	public void prepare() {
		switch (operation_type) {
		case add:
			this.netEntity = new AddressEntity(recipientName, recipientAddress,
					recipientMobile, recipientPostCode);
			break;
		case update:
			this.netEntity = new AddressEntity(recipientName, recipientAddress,
					recipientMobile, recipientPostCode, recipientAddressId);
			break;
		case delete:
			this.netEntity = new AddressEntity(recipientAddressId);
			break;
		case get:
			this.netEntity = new AddressEntity();
			break;
		default:
			break;
		}
	}
}
